package com.gitee.ly;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.net.InetAddress;
import java.net.UnknownHostException;

@RestController
public class TestController {
    @Value("${server.port}")
    int appPort;

    @Autowired
    private RemoteSpringboot2Main remoteSpringboot2Main;

    @GetMapping("getStrOnce")
    public String getStrOnce() throws UnknownHostException {
        String ip = InetAddress.getLocalHost().getHostAddress();
        String s = "springboot2-main1   " + ip + ":" + appPort;

        return s;
    }


    @GetMapping("getStr")
    public String getStr() throws UnknownHostException {
        String ip = InetAddress.getLocalHost().getHostAddress();
        String s = "springboot2-main1   " + ip + ":" + appPort;

        return s + " remote return: " + remoteSpringboot2Main.getStrOnce();
    }
}
